﻿<Window x:Class="AppDemo.MessageWindowDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
        xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
        xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
        xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
        xmlns:local="clr-namespace:AppDemo" WindowStyle="None"  AllowsTransparency="True"
        Title="MessageWindowDialog" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <local:ConditionalConverter x:Key="ConditionalConverter" />
        <local:MsgBoxImageConverter x:Key="ImageConverter"/>
        <LinearGradientBrush x:Key="FileCopyHeaderBackgroundBrush"
						 EndPoint="1,0.5" StartPoint="0,0.5">
            <GradientStop Color="#FF135279" Offset="0"/>
            <GradientStop Color="#FF277D8F" Offset="1"/>
            <GradientStop Color="#FF135279" Offset="0.575"/>
        </LinearGradientBrush>
        <DrawingImage x:Key="CloseButton">
            <DrawingImage.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Geometry="F1 M 1.98611,1.98611L 13.9861,13.9861">
                            <GeometryDrawing.Pen>
                                <Pen Thickness="3" LineJoin="Round" Brush="#FFFFFFFF"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                        <GeometryDrawing Geometry="F1 M 13.9861,1.98611L 1.98611,13.9861">
                            <GeometryDrawing.Pen>
                                <Pen Thickness="3" LineJoin="Round" Brush="#FFFFFFFF"/>
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingImage.Drawing>
        </DrawingImage>

    </Window.Resources>
    <!-- Background="{x:Null}"-->
    <Grid  DataContext="{Binding .,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MessageWindowDialog}}}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />

        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition MinHeight="25"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
       
        
        <Rectangle Margin="1" Fill="{StaticResource FileCopyHeaderBackgroundBrush}"></Rectangle>
        <TextBlock Text="{Binding Caption,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MessageWindowDialog}}}"
                   Foreground="White" TextTrimming="CharacterEllipsis" FontSize="16"
                   Margin="14,0,38,0" VerticalAlignment="Center"/>
    
            <docking:TitleBarButton ToolTip="Close" Click="TitleBarButton_Click" Padding="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" BorderThickness="0">
            <docking:TitleBarButton.Resources>
                <Style TargetType="{x:Type docking:TitleBarButton}">
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static themes:DockingCommonDictionary.ToolWindowContainerTitleBarBackgroundActiveBrushKey}}"></Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </docking:TitleBarButton.Resources>
            <Image Stretch="None" Source="{DynamicResource CloseButton}" />
               
        </docking:TitleBarButton>
        
       
                <Border Width="350" Grid.Row="1">
                    <StackPanel>
                        <Grid  Margin="18,10,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Image Height="32" Width="32"  Margin="0,0,5,0" x:Name="image"  Source="{Binding MsgBoxImage,Converter={StaticResource ImageConverter},RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MessageWindowDialog}}}">
                                <Image.Visibility>
                                    <MultiBinding Converter="{StaticResource ConditionalConverter}">
                                        <Binding Path="Source" RelativeSource="{RelativeSource Mode=Self}"/>
                                        <Binding Source="{x:Static Visibility.Visible}" />
                                        <Binding Source="{x:Static Visibility.Collapsed}" />
                                    </MultiBinding>
                                </Image.Visibility>
                            </Image>
                            <TextBlock Grid.Column="1" Margin="0,0,4,0"
                                           Foreground="#FF475C69" FontWeight="Bold" VerticalAlignment="Center"
                                              Text="{Binding MsgBoxContent,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MessageWindowDialog}}}"
                                       TextWrapping="Wrap" /> 
                    <TextBlock Margin="0,5,5,0" 
                               TextWrapping="Wrap"
                               Text="{Binding MsgBoxDetail}"
                                        Foreground="#FF475C69" FontWeight="Bold" VerticalAlignment="Center"
                                        HorizontalAlignment="Left"
                                        Grid.Row="1" Grid.ColumnSpan="2">
                                 <TextBlock.Visibility>
                                    <MultiBinding Converter="{StaticResource ConditionalConverter}">
                                        <Binding ElementName="moreInfoExpander" Path="IsExpanded"/>
                                        <Binding Source="{x:Static Visibility.Visible}" />
                                        <Binding Source="{x:Static Visibility.Collapsed}" />
                                    </MultiBinding>
                                </TextBlock.Visibility>
                    </TextBlock>
                    <TextBlock Margin="0,5,5,0" Text="{Binding AutoCloseTip,UpdateSourceTrigger=PropertyChanged}"
                                        Foreground="#FF475C69" FontWeight="Bold" VerticalAlignment="Center"
                                        HorizontalAlignment="Right"
                                        Grid.Row="2" Grid.ColumnSpan="2">
                                 <TextBlock.Visibility>
                                    <MultiBinding Converter="{StaticResource ConditionalConverter}">
                                        <Binding Path="AutoClose"/>
                                        <Binding Source="{x:Static Visibility.Visible}" />
                                        <Binding Source="{x:Static Visibility.Collapsed}" />
                                    </MultiBinding>
                                </TextBlock.Visibility>
                            </TextBlock>
                           
                        </Grid>
                        <Grid Grid.Row="1" Background="#F0F0F0" MinHeight="40" Margin="0,10,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                    <Expander x:Name="moreInfoExpander" HorizontalAlignment="Left" VerticalAlignment="Center"  Margin="18,0,0,0">
                        <Expander.Resources>
                            <Style TargetType="Expander">
                                <Style.Triggers>
                                    <Trigger Property="IsExpanded" Value="True">
                                        <Setter Property="Header" Value="隐藏详细信息"/>
                                    </Trigger>
                                    <Trigger Property="IsExpanded" Value="False">
                                        <Setter Property="Header" Value="显示详细信息"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Expander.Resources>
                        <Expander.Visibility>
                            <MultiBinding Converter="{StaticResource ConditionalConverter}">
                                <Binding Path="IsShowDetail"/>
                                <Binding Source="{x:Static Visibility.Visible}" />
                                <Binding Source="{x:Static Visibility.Collapsed}" />
                            </MultiBinding>
                        </Expander.Visibility>
                    </Expander>
                            <ItemsControl Grid.Column="1" Margin="0,0,4,0"
                                           HorizontalAlignment="Right" VerticalAlignment="Center"
                                          x:Name="Part_ActionButton">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <UniformGrid Columns="{Binding ButtonCount,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MessageWindowDialog}}}"></UniformGrid>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.Resources>
                                    <Style TargetType="{x:Type ribbon:Button}">
                                        <Setter Property="MinWidth" Value="72"/>
                                        <Setter Property="Margin" Value="4,0,0,0"/>
                                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                    </Style>
                                </ItemsControl.Resources>
                            </ItemsControl>
                        </Grid>
                    </StackPanel>
                </Border>
    </Grid>
</Window>
